interface ITreeNode {
  value: number
  left: ITreeNode | null
  right: ITreeNode | null
}
const arr: number[] = []

// 二叉树前序遍历
function preOrderTraverse (node: ITreeNode | null) {
  if (node == null) return
  arr.push(node.value)
  preOrderTraverse(node.left)
  preOrderTraverse(node.right)
}
// 二叉树中序遍历
function inOrderTraverse (node: ITreeNode | null) {
  if (node == null) return
  preOrderTraverse(node.left)
  arr.push(node.value)
  preOrderTraverse(node.right)
}
// 二叉树后序遍历
function postOrderTraverse (node: ITreeNode | null) {
  if (node == null) return
  preOrderTraverse(node.left)
  preOrderTraverse(node.right)
  arr.push(node.value)
}
function getKthValue (node: ITreeNode, k: number): number | null {
  inOrderTraverse(node)
  return arr[k - 1] || null
}